	
	function flagChange(){
		$('changesbutton').disabled = false;
		window.onbeforeunload = function(e){
		  var s = 'You have unsaved changes.';
		  if (e) e.returnValue = s;
		  return s;
		};
	}
	
	function unflagChange(){
		$('changesbutton').disabled = true;
		window.onbeforeunload = function(){}
	}
		
	var cp_onload = function(win){
		Event.observe(win, 'keydown', win.parent.flagChange)
	}

	window.queue(function(){
		Chrome.load({
			Selection:0
		});
	});
	
	var Database = {
		dbid:'<?=$this->dbn?>',
		test:function(){
			var ini = dtbini.getCode();
			Smajax.exec('testDatabase', {dbid:this.dbid, ini:ini, name:$('dbname').value.trim()});
		},
		save:function(){
			var ini = dtbini.getCode();
			Smajax.exec('saveDatabase', {dbid:this.dbid, ini:ini, name:$('dbname').value.trim()});
		}
	}